﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.member
{
    public partial class configshop_articlelist : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cbuser u = cbuser.getcuruser();
                string id = u.cbuserid.ToString();
                cbshopcss sc = cbshopcss.findorcreate(id);
                string css = sc.getstylestring();
                Literalcss.Text = css;

                //bind1();
                bind2();

            }
        }


    

        /// <summary>
        /// 绑定基础分类
        /// </summary>
        private void bind2()
        {
            string cataid = "0";
            if (this.Request.Params["kid"] != null)
            {
                cataid = this.Request.Params["kid"].ToString();
            }
            if (cataid == "0")
            {
                if (this.Request.Params["value"] != null)
                {
                    cataid = this.Request.Params["value"].ToString();
                }
            }
            if (cataid != "")
            {
                cbcata c = cbcata.Find(" cbcataid = '" + cataid + "' ");
                Label1.Text = c.cbname.ToString();
            }
            string sql = "";
            //sql += " select 1 as shunxu,* from vcblist where cblisttype = '发帖' ";
            //sql += " and zhidingcataid in ( ";
            //sql += " select cbcataid from cbcata where cbcataid = '" + cataid +
            //    "' or cbcataid = '" + c.pid1.ToString() +
            //    "' or cbcataid = '" + c.pid2.ToString() +
            //    "' or cbcataid = '" + c.pid3.ToString() +
            //    "' or cbcataid = '" + c.pid4.ToString() +
            //    " ') union "
            //    ;


            
            //if (AliApi.appInstanceId != "")
            //{
            //    sql += " and area = '" + AliApi.appInstanceId + "' ";
            //}
            if (this.Request.Params["kid"] != null)
            {
                sql += " select top 10  2 as shunxu, * from vcblist where cblisttype = '发帖' ";
                sql += " and cbcataid = '" + this.Request.Params["kid"].ToString() + "' ";
            }
            else
            {
                sql += " select top 50  2 as shunxu, * from vcblist where cblisttype = '发帖' ";
                if (this.Request.Params["value"] != null)
                {
                    sql += " and cbcataid = '" + this.Request.Params["value"].ToString() + "' ";
                }
            }
            sql += "  order by shunxu, paixu desc, jccreatedate desc ,jccreatetime desc ";
            DataTable dt = RuleCode.Common.SqlHelper.Instance.ExecuteQuery(sql).Tables[0];
            GridView_list.DataSource = dt;
            GridView_list.DataBind();



        }




    }
}
